package com.jxwifi.cloud.quickcleanserver.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;


/**
 * 定位消息弹框
 * Created by ${oushuhua} on 2017/6/30.
 */

public class AlterLocation {

    public static void popAlterDialog(final Context ctx, final String msgFlg, String msgInfo) {
        new AlertDialog.Builder(ctx)
                .setTitle(msgFlg)//定位服务已关闭
                .setMessage(msgInfo)
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setPositiveButton("设置", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //前往应用详情界面
                        try {
                            Uri packUri = Uri.parse("package:" + ctx.getPackageName());
                            Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packUri);
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            ctx.startActivity(intent);
                        } catch (Exception e) {
                            //showShortMsg("跳转失败");
                            //MToast.shortToast(ctx, "跳转失败");
                        }
                        dialog.dismiss();
                    }
                }).create().show();
    }

    public static void popSettingDialog(final Context ctx, final String msgFlg, String msgInfo) {
        new AlertDialog.Builder(ctx)
                .setTitle(msgFlg)//定位服务已关闭
                .setMessage(msgInfo)
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .setPositiveButton("设置", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //前往应用详情界面

                        dialog.dismiss();
                    }
                }).create().show();
    }

}
